
import { initSearch } from "@/utils/form";
import { getPagination, reset, getTableData } from "@/utils/table";

import { getList } from "@/api/user";

export default {
  data() {
    return {

      // 查询条件
      searchForm: {
        initSearch: (db) => initSearch(db, true, "searchForm", this),
        // 刷新方法
        refresh: null,
        // 使用表单组件后所有的值
        form: null,
        options: [
          {
            type: "input",
            value: "",
            label: "",
            prop: "key",
            attrs: {
              style: {
                width: "300px"
              },
              clearable: true,
              placeholder: "请输入工号 / 姓名 / 部门/组织 / 职务描述"
            }
          }
        ],
        btnList: {
          show: true,
          size: "mini",
          btnList: [
            {
              label: "查询",
              mthods: (form) => this.search(form),
              icon: "el-icon-search",
              type: "primary"
            },
            {
              label: "重置",
              mthods: (form, search) => reset(["codeNumber", "mainPondCode", "sonLineCode", "reportType"], form, search),
              icon: "el-icon-refresh"
            }

          ]

        }
      }

    };
  },
  methods: {
    // 查询
    async search(form) {
      // 将分页数据插入查询表单
      const _form = getPagination(form, "dataGrid", this);
      getTableData("dataGrid", this, getList, _form, true, (data) => {
        this.dataGrid.data = data.map(item => {
          item.statusName = item.status ? "禁用" : "启用";
          return item;
        });
      });
    }
  }
};
